package com.atguigu.jxc.controller;

import com.atguigu.jxc.domain.ServiceVO;
import com.atguigu.jxc.entity.Customer;
import com.atguigu.jxc.entity.Supplier;
import com.atguigu.jxc.service.CustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * TODO
 *
 * @author Mr.zhao
 * @version 1.0
 * @date 2021/12/31 11:47
 *
 * http://localhost:8080/customer/list
 */
@RestController
@RequestMapping("/customer")
public class CustomerController {


    @Autowired
    private CustomerService customerService;
    /**分页查询客户列表
     * Integer page（当前页数）, Integer rows（每页显示的记录数）, String supplierName
     * @return
     */
    @PostMapping("/list")
    public Map<String,Object> getSupplierList(Integer page,
                                              Integer rows,
                                              String supplierName){
        return customerService.getCustomerList(page,rows,supplierName);
    }

    @PostMapping("/save")
    public ServiceVO saveOrUpdateSupplier(Customer customer){

        customerService.saveOrUpdateCustomer(customer);
        return ServiceVO.Ok();
    }

    /**
     * 删除客户列表
     *
     * http://localhost:8080/supplier/delete
     */
    @PostMapping("/delete")
    public ServiceVO deleteSuppliers(String ids){


        customerService.delete(ids);
        return ServiceVO.Ok();
    }
}
